import { Controller } from 'egg';
// import { Op } from 'sequelize';
import { ABLED, STATUS } from '../../common/constants';

export default class OrderController extends Controller {
  constructor(ctx) {
    super(ctx);
  }

  async index() {
    const shop_id = this.ctx._shop.id;
    const shop = await this.app.model.Shop.findOne({ where: { id: shop_id } });
    const solution = await this.service.template.template.detailPublic(shop.template_id, 1, shop_id)
    const lucky = await this.service.template.template.getLuckyData(shop_id);
    this.ctx.success({
      data: {
        solution,
        lucky
      }
    })

    // const fetchArr: any = [];

    // const whereParams = {
    //   status: ABLED.ENABLED
    // };

    // // 首页Banner轮播图
    // fetchArr.push(this.ctx.sassmodel.Ad.findAll({
    //   where: {},
    //   limit: 5,
    //   order: [['id', 'DESC']],
    // }));

    // // 首页菜单
    // fetchArr.push(this.ctx.sassmodel.Nav.findAll({
    //   where: {
    //     status: STATUS.ENABLED
    //   },
    //   attributes: [
    //     'name', 'type', 'url', 'icon', 'id', 'param', 'target'
    //   ],
    //   limit: 4,
    //   order: [['sort', 'DESC']],
    // }));


    // // 营销分类
    // fetchArr.push(this.ctx.sassmodel.Market.findAll({
    //   where: whereParams,
    //   include: [
    //     {
    //       model: this.ctx.model.Goods,
    //       attributes: [
    //         'name', 'nick', 'brief', 'main_pic', 'stock',
    //         'cost_price', 'market_price', 'price', 'id'
    //       ]
    //     }
    //   ],
    //   limit: 5,
    //   order: [['sort', 'DESC']],
    // }));


    // const [ad, menus = [], market = []] = await Promise.all(fetchArr);

    // this.ctx.success({
    //   data: {
    //     ad,
    //     market,
    //     menus
    //   },
    // });
  }


}